try {
  require("./background/Service/Test")
  process.env.NODE_ENV = "dev"
  console.log("env mode: dev")
} catch (error) {
  console.log(". . . .")
  process.env.NODE_ENV = "production"
}

require("./background/lib/awaitCall")
const AppDelegate = require("./background/Service/AppDelegate").default
const Utils = require("./background/Generate/Utils").default
const ChromeCtl = require("./background/Generate/ChromeCtl").default
const InAppRoute = require("./background/Route/InAppRoute").default
const ExternalRoute = require("./background/Route/ExternalRoute").default
const CommonService = require("./background/Service/CommonService").default
// 项目准备工作入口
function main() {
  Utils.Init()
  awaitFunc()
}
async function awaitFunc() {
  await CommonService.parsePageJsonFile()
}
main()

chrome.runtime.onMessage.addListener(InAppRoute)
chrome.runtime.onMessageExternal.addListener(ExternalRoute)

chrome.tabs.onUpdated.addListener(AppDelegate.tabsOnUpdated)

process
  .on('unhandledRejection', AppDelegate.onUncaughtException)
  .on('uncaughtException', AppDelegate.onUncaughtException)
